Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set "get:schema/" API endpoint as deprecated #3813

Merged

Conversation

BaptisteGi
Copy link
Contributor

@BaptisteGi BaptisteGi commented Jul 11, 2024

I set the get "schema/" API endpoint as deprecated and flagged it so it's not included in the schema anymore. Also, it appears that this endpoint is consumed at various places in the SDK (This will be addressed in a separated PR).

#1363

@BaptisteGi BaptisteGi added type/bug Something isn't working as expected type/documentation Improvements or additions to documentation group/backend Issue related to the backend (API Server, Git Agent) labels Jul 11, 2024
@BaptisteGi BaptisteGi requested a review from ogenstad July 11, 2024 09:37
@BaptisteGi BaptisteGi linked an issue Jul 11, 2024 that may be closed by this pull request
Copy link

cla-assistant bot commented Jul 11, 2024

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot removed the type/documentation Improvements or additions to documentation label Jul 11, 2024
@BaptisteGi BaptisteGi marked this pull request as draft July 11, 2024 10:02
@ogenstad
Copy link
Contributor

Looks like this is problematic as we have methods in the SDK that's using the incorrect URL.

For now we can perhaps instead do something like this:

diff --git a/backend/infrahub/api/schema.py b/backend/infrahub/api/schema.py
index 281cac8ba..cac117343 100644
--- a/backend/infrahub/api/schema.py
+++ b/backend/infrahub/api/schema.py
@@ -135,7 +135,7 @@ def evaluate_candidate_schemas(


 @router.get("")
-@router.get("/")
+@router.get("/", include_in_schema=False, deprecated=True)

Then we need to change some methods in the SDK such as schema.fetch(), this part should be done first then we can remove the router get in a future version instead once the SDK package have been updated and the new versions are in use.

@BaptisteGi
Copy link
Contributor Author

I can see here

url = f"{self.client.address}/api/schema/?{query_params}"
that sdk expects a url likef"{self.client.address}/api/schema/?{query_params}". Wondering if the correct/standard way shouldn't be without the "/" i.e /api/schema?{query_params}

@ogenstad
Copy link
Contributor

I can see here

url = f"{self.client.address}/api/schema/?{query_params}"

that sdk expects a url likef"{self.client.address}/api/schema/?{query_params}". Wondering if the correct/standard way shouldn't be without the "/" i.e /api/schema?{query_params}

Yes that would be the correct approach. As you might note we probably have this duplicated in both the sync and async functions.

@BaptisteGi BaptisteGi marked this pull request as ready for review July 11, 2024 11:58
@BaptisteGi
Copy link
Contributor Author

I can see here

url = f"{self.client.address}/api/schema/?{query_params}"

that sdk expects a url likef"{self.client.address}/api/schema/?{query_params}". Wondering if the correct/standard way shouldn't be without the "/" i.e /api/schema?{query_params}

Yes that would be the correct approach. As you might note we probably have this duplicated in both the sync and async functions.

I'll maybe create a separated PR / Issue to fix all usage we have across the SDK, any opinion on that?

Copy link
Contributor

@ogenstad ogenstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though I'd remove the part in the description that it fixes the issue (to avoid having the issue be automatically closed). Also perhaps you can change the title of the PR to reflect that the work took a different path. The titles are currently used for the automated part of the release notes (though this might change soon)

@BaptisteGi BaptisteGi changed the title Remove duplicated router get schema statement Set "get:schema/" API endpoint as deprecated Jul 12, 2024
@BaptisteGi BaptisteGi merged commit 0a2e395 into develop Jul 12, 2024
45 checks passed
@BaptisteGi BaptisteGi deleted the bgi-20240711-remove-duplicate-schema-endpoint-1363 branch July 12, 2024 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group/backend Issue related to the backend (API Server, Git Agent) type/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

task: Remove duplicate /api/schema endpoint in docs
2 participants